package cubelabs.nexus.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * Handles requests for the application home page.
 */
@Controller
public class LoginController {
	
	private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
	
	/**
	 * Simply selects the home view to render by returning its name.
	 */
	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public ModelAndView login() {
		logger.info("Welcome home! the client locale is ");
		ModelAndView modelAndView  = new ModelAndView("login");
		return modelAndView;
		
	}

	@RequestMapping(value = "/signup", method = RequestMethod.GET)
	public ModelAndView signup() {
		logger.info("Welcome home! the client locale is ");
		ModelAndView modelAndView  = new ModelAndView("login");
		return modelAndView;
		
	}

	@RequestMapping(value = "/")
	public String home(){
		
		return "index";
	}
	
	@RequestMapping(value = "/logout")
	public String logout(final HttpServletRequest request){
		request.getSession().removeAttribute("user");
		
		return "index";
	}
	
}

